package cn.bluethink.eguan.core.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Id;

import cn.bluethink.eguan.model.core.EgBag;
import cn.bluethink.eguan.model.core.EgGoods;
import cn.bluethink.eguan.model.core.EgOType;
import cn.bluethink.eguan.model.core.EgObject;

/**
 * 兑换商品+兑换人（名称）联合查询结果
 * 
 * @author 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.3.0
 * @brief 驿馆+产品
 * @note 修订历史：
 *       1.wanglei于2018/12/04设计并构建初始版本v0.3.0
 */
public class GoodsHistoryEntity implements Serializable {

    private static final long serialVersionUID = -5315113180226974844L;

    // 主键ID
    @Id
    private Long id;

    // 商品ID
    private Long gdid;

    // 商品类型
    private Integer otype;

    // 商品标题
    private String name;

    // 商品图标
    private String icon;

    // 商品价格
    private Integer price;

    // 商品数量
    private Integer number;

    // 商品创建者
    private Long uid;

    // 商品创建时间
    private Date ctime;

    // 商品更新时间
    private Date utime;

    // 包裹ID
    private Long bagid;

    // 商品所属者的类型
    private Integer ownerOtype;

    // 商品所属者
    private Long ownerOid;
    
    // 商品所有者名称
    private String uname;

    // 商品的状态
    private Integer status;

    private Integer checkStatus;


    /**
     * 转为业务模型
     * 
     * @return
     */
    public EgGoods createEgGoods() {
        EgGoods goods = new EgGoods();
        // 返回时以主键方式
        goods.setId(id);
        goods.setName(name);
        goods.setIcon(icon);
        goods.setPrice(price);
        goods.setNumber(number);
        if (bagid != null && bagid > 0) {
            goods.setBag(new EgBag(bagid, null));
        } else {
            goods.setBag(null);
        }
        if (ownerOtype != null && ownerOid != null && ownerOtype > 0 && ownerOid > 0) {
            goods.setOwner(new EgObject(ownerOid, uname, new EgOType(ownerOtype, null)));
        } else {
            goods.setOwner(null);
        }
        goods.setUtime(utime);
        goods.setStatus(status);
        goods.setCheckStatus(checkStatus);
        return goods;
    }


    public Long getId() {
        return id;
    }


    public void setId(Long id) {
        this.id = id;
    }


    public Long getGdid() {
        return gdid;
    }


    public void setGdid(Long gdid) {
        this.gdid = gdid;
    }


    public Integer getOtype() {
        return otype;
    }


    public void setOtype(Integer otype) {
        this.otype = otype;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    public String getIcon() {
        return icon;
    }


    public void setIcon(String icon) {
        this.icon = icon;
    }


    public Integer getPrice() {
        return price;
    }


    public void setPrice(Integer price) {
        this.price = price;
    }


    public Integer getNumber() {
        return number;
    }


    public void setNumber(Integer number) {
        this.number = number;
    }


    public Long getUid() {
        return uid;
    }


    public void setUid(Long uid) {
        this.uid = uid;
    }


    public Date getCtime() {
        return ctime;
    }


    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }


    public Date getUtime() {
        return utime;
    }


    public void setUtime(Date utime) {
        this.utime = utime;
    }


    public Long getBagid() {
        return bagid;
    }


    public void setBagid(Long bagid) {
        this.bagid = bagid;
    }


    public Integer getOwnerOtype() {
        return ownerOtype;
    }


    public void setOwnerOtype(Integer ownerOtype) {
        this.ownerOtype = ownerOtype;
    }


    public Long getOwnerOid() {
        return ownerOid;
    }


    public void setOwnerOid(Long ownerOid) {
        this.ownerOid = ownerOid;
    }


    public String getUname() {
        return uname;
    }


    public void setUname(String uname) {
        this.uname = uname;
    }


    public Integer getStatus() {
        return status;
    }


    public void setStatus(Integer status) {
        this.status = status;
    }


    public Integer getCheckStatus() {
        return checkStatus;
    }


    public void setCheckStatus(Integer checkStatus) {
        this.checkStatus = checkStatus;
    }

}
